// admissWrite.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    leaveMsg:{
      placeholderTxt: "请输入跟进内容",
      gtBtnTxt: "保存"
    },
    studentId :0,
    communicateContent : ""
  },
  /** 
   * 评语发布
   */
  formSubmit: function(e){
    var that = this;
    var studentId = that.data.studentId;
    var communicateContent = e.detail.value.textarea;
    console.log(e.detail.value.textarea)
    wx.request({
      url: app.globalData.http + "addCommunicate.do",
      header: {
        'content-type': 'application/json'
      },
      data: {
        studentId:parseInt(studentId),
        communicateContent: communicateContent,
        busId: parseInt(wx.getStorageSync("busId")),
        employeesId: parseInt(wx.getStorageSync("employeesId")),
        schoolId: parseInt(wx.getStorageSync("schoolId"))
      },
      success: function(res){
        console.log("评语发布成功返回数据==",res);
        console.log("communicateContent===",communicateContent);
        console.log("studentId===",studentId);
        var code = res.data.code;
        if(code == 100){
          if(communicateContent == "" || communicateContent == null){
            wx.showToast({
              title: '不能为空',
              image: "/img/ico/fail.png",
              duration: 2000  
            });
            return false;
          } else{
            wx.navigateTo({
              url: "/pages/admissSuccess/admissSucess"
            })
          } 
        }else{
          wx.showToast({
            title: '发布失败',
            image: "/img/ico/fail.png",
            duration: 2000  
          });
          return
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    console.log("新增跟进记录==",options.id);
    that.setData({
      studentId : options.id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})